<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
	<link rel="shortcut icon" href="${ctx}/favicon.ico"> 
 	<link href="${ctx}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${ctx}/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>
<body>
<form class="form-horizontal" action="##"> 
    <div class="form-group">
        <label class="col-sm-3 control-label">商品名称：</label>

        <div class="col-sm-4">
            <select id="goods_id" name="goods_id" class="form-control goods_id">
                <c:forEach var="goodslist" items="${goods_list}">
                	<c:if test="${goodslist.goods_name==purchase.goods_name}">
                		<option value="${goodslist.goods_id}" selected>${goodslist.goods_name}</option>
                	</c:if>
                	<c:if test="${goodslist.goods_name!=purchase.goods_name}">
                		<option value="${goodslist.goods_id}" >${goodslist.goods_name}</option>
                	</c:if>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">价格：</label>
        <div class="col-sm-4">
            <input type="text" class="form-control" name="price" value="${purchase.price}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">规格：</label>

        <div class="col-sm-4">
            <select id="unit" name="unit" class="form-control">
                <option value="斤">斤</option>
                <option value="公斤">公斤</option>
                <option value="箱">箱</option>
                <option value="袋">袋</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">数量：</label>
        <div class="col-sm-4">
            <input type="text"  class="form-control" name="number" value="${purchase.number}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">采购人：</label>
        <div class="col-sm-4">
            <select id="purchase_people_id" name="purchase_people_id" class="form-control">
                <c:forEach var="peoplelist" items="${people_list}">
                	<c:if test="${peoplelist.purchase_name==purchase.purchase_name}">
                		<option value="${peoplelist.purchase_people_id}"selected>${peoplelist.purchase_name}</option>
                	</c:if>
                	<c:if test="${peoplelist.purchase_name!=purchase.purchase_name}">
                		<option value="${peoplelist.purchase_people_id}">${peoplelist.purchase_name}</option>
                	</c:if>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">厂商：</label>
        <div class="col-sm-4">
            <select id="supplier_id" name="supplier_id" class="form-control">
                <c:forEach var="suppliers" items="${supplier_list}">
                	<c:if test="${suppliers.supplier_==purchase.supplier_}">
                		<option value="${suppliers.supplier_id}" selected>${suppliers.supplier_}</option>
                	</c:if>
                	<c:if test="${(suppliers.supplier_)!=(purchase.supplier_)}">
                		<option value="${suppliers.supplier_id}">${suppliers.supplier_}</option>
                	</c:if>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">备注：</label>
        <div class="col-sm-4">
            <input type="text" class="form-control" name="remark" value="${purchase.remark}">
        </div>
    </div>
    <input type="hidden" name="purchase_id" value="${purchase.purchase_id}"/>
    <div class="form-group" style="margin-top:30px;">
        <div class="col-sm-offset-4 col-sm-8">
            <div class="btn btn-sm btn-white" type="submit" onclick="submitForm()">修改采购计划</div>
        </div>            
    </div>
</form>

</body>
	<!-- 全局js -->
    <script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctx}/dist/layer-v3.1.1/layer/layer.js"></script>
<script type="text/javascript">
	$("#unit").val("${purchase.unit}");	
	
	function submitForm() {
		//alert($('#purchase_people_id').val());
		$.get('${ctx}/PurchaseServlet/editInfo',$('form').serialize(),function(data){			
			if(data){
				parent.layer.msg('修改成功！');
				window.parent.location.reload();//刷新父页面
				parent.layer.close(index);//关闭当前的弹窗
			}else{
				parent.layer.msg('修改失败！');
				window.parent.location.reload();//刷新父页面
				parent.layer.close(index);//关闭当前的弹窗
			}
		});
	}
</script>    

</html>